<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue Example</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script>
    window.onload = function() {
      new Vue({
        el: '#app',
        data: {
          currentTab: 0, // 默认显示第一个选项卡
          tabs: [
            { title: 'Tab 1', content: '这是选项卡1的内容。' },
            { title: 'Tab 2', content: '这是选项卡2的内容。' },
            { title: 'Tab 3', content: '这是选项卡3的内容。' }
          ]
        },
        methods: {
          switchTab(index) {
            this.currentTab = index; // 切换当前选项卡
          }
        }
      });
    };
  </script>
  <style>
    .tabs {
      border: 1px solid #ccc;
      border-radius: 4px;
      width: 300px;
      margin: 20px auto;
    }
    .tabs-header {
      display: flex;
      border-bottom: 1px solid #ccc;
      background-color: #f9f9f9;
    }
    .tab-title {
      padding: 10px 20px;
      cursor: pointer;
    }
    .tab-title.active {
      font-weight: bold;
      color: #42b983;
    }
    .tabs-content {
      padding: 20px;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="tabs">
      <div class="tabs-header">
        <span 
          v-for="(tab, index) in tabs" 
          :key="index" 
          :class="['tab-title', { active: currentTab === index }]"
          @click="switchTab(index)"
        >
          {{ tab.title }}
        </span>
      </div>
      <div class="tabs-content">
        <div v-for="(tab, index) in tabs" v-show="currentTab === index">
          {{ tab.content }}
        </div>
      </div>
    </div>
  </div>
</body>
</html>